{% extends 'base.html' %}

{% block content %}
<div class="container-fluid">
  <h2 class="m-lg-4 m-md-3 m-sm-2">{% block content_title %}近期动态{% endblock %}</h2>
  <div class="row row-gap-md-4 row-gap-2 row-cols-md-2 row-cols-1 mx-md-5 mx-2">
    {% for article in articles_page.object_list %}
    <div class="container col">
      <a href="{{ SITEURL }}/{{ article.url }}" class="text-decoration-none">
      <div class="card">
        <div class="row g-0">
          {% if article.featured_image %}
          <div class="col-md-4">
            <img src="{{ article.featured_image }}" class="img-fluid rounded-start">
          </div>
          {% endif %}
          <div class="{% if article.featured_image %}col-md-8{% else %}col-md-12{% endif %}">
            <div class="card-body">
              <h5 class="card-title">{{ article.title }}</h5>
              {% if article.metadata['summary'] %}
                <p class="card-text">{{ article.summary }}</p>
              {% endif %}
              <p class="card-text"><small class="text-body-secondary">{{ article.date.strftime('%Y-%m-%d') }}发布于{{ article.category.name }}</small></p>
            </div>
          </div>
        </div>
      </div>
    </a>
    </div>
    {% endfor %}
  </div>
  {% if DEFAULT_PAGINATION %}
  <div class="row mt-lg-5 mt-md-3 mt-sm-2">
    <div class="container">
      {% if articles_page.has_next() %}
      <a href="{{ SITEURL }}/{{ articles_next_page.url }}" class="float-start">
        <button type="button" class="btn btn-light" style="background-color: #dedede;"><i class="bi bi-arrow-left"></i> 更旧的内容</button>
      </a>
      {% endif %}
      {% if articles_page.has_previous() %}
      <a href="{{ SITEURL }}/{{ articles_previous_page.url }}" class="float-end">
        <button type="button" class="btn btn-light" style="background-color: #dedede;">更新的内容 <i class="bi bi-arrow-right"></i></button>
      </a>
      {% endif %}
    </div>
  </div>
  {% endif %}
</div>


<!-- {% for article in articles_page.object_list %} -->

<!-- <article>
      <header><h2><a href="{{ SITEURL }}/{{ article.url }}"></a>{{ article.title }}</h2></header>
      <section>{{ article.summary }}</section>
    </article> -->
<!-- {% endfor %} -->
{% endblock %}